follow-up r61917 - stylize for coding conventions
authorMark A. Hershberger <mah@users.mediawiki.org>
Wed, 3 Feb 2010 16:27:04 +0000 (16:27 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Wed, 3 Feb 2010 16:27:04 +0000 (16:27 +0000)
tests/MediaWikiAPITest.php

index 95ca074..a08a9c9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once("MediaWikiAPI_TestCase.php");
+require_once( "MediaWikiAPI_TestCase.php" );
 
 class MediaWikiAPITest extends MediaWikiAPI_TestCase {
 
@@ -10,49 +10,49 @@ class MediaWikiAPITest extends MediaWikiAPI_TestCase {
 
        function testApi() {
                /* Haven't thought about test ordering yet -- but this depends on HttpTest.php */
-               $resp = Http::get(self::$apiUrl."?format=xml");
+               $resp = Http::get( self::$apiUrl . "?format=xml" );
 
-               libxml_use_internal_errors(true);
-               $sxe = simplexml_load_string($resp);
-               $this->assertNotType("bool", $sxe);
-               $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
+               libxml_use_internal_errors( true );
+               $sxe = simplexml_load_string( $resp );
+               $this->assertNotType( "bool", $sxe );
+               $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
        }
 
        function testApiLoginNoName() {
-               $resp = Http::post(self::$apiUrl."?action=login&format=xml",
-                                                  array("postData" => array(
-                                                               "lgname" => "",
-                                                               "lgpassword" => self::$passWord)));
-               libxml_use_internal_errors(true);
-               $sxe = simplexml_load_string($resp);
-               $this->assertNotType("bool", $sxe);
-               $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
+               $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
+                                                  array( "postData" => array(
+                                                                        "lgname" => "",
+                                                                        "lgpassword" => self::$passWord ) ) );
+               libxml_use_internal_errors( true );
+               $sxe = simplexml_load_string( $resp );
+               $this->assertNotType( "bool", $sxe );
+               $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
                $a = $sxe->login[0]->attributes()->result;
                $this->assertEquals( ' result="NoName"', $a->asXML() );
        }
 
        function testApiLoginBadPass() {
-               $resp = Http::post(self::$apiUrl."?action=login&format=xml",
-                                                  array("postData" => array(
-                                                               "lgname" => self::$userName,
-                                                               "lgpassword" => "bad")));
-               libxml_use_internal_errors(true);
-               $sxe = simplexml_load_string($resp);
-               $this->assertNotType("bool", $sxe);
-               $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
+               $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
+                                                  array( "postData" => array(
+                                                                        "lgname" => self::$userName,
+                                                                        "lgpassword" => "bad" ) ) );
+               libxml_use_internal_errors( true );
+               $sxe = simplexml_load_string( $resp );
+               $this->assertNotType( "bool", $sxe );
+               $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
                $a = $sxe->login[0]->attributes()->result;
                $this->assertEquals( ' result="WrongPass"', $a->asXML() );
        }
 
        function testApiLoginGoodPass() {
-               $resp = Http::post(self::$apiUrl."?action=login&format=xml",
-                                                  array("postData" => array(
-                                                               "lgname" => self::$userName,
-                                                               "lgpassword" => self::$passWord)));
-               libxml_use_internal_errors(true);
-               $sxe = simplexml_load_string($resp);
-               $this->assertNotType("bool", $sxe);
-               $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
+               $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
+                                                  array( "postData" => array(
+                                                                        "lgname" => self::$userName,
+                                                                        "lgpassword" => self::$passWord ) ) );
+               libxml_use_internal_errors( true );
+               $sxe = simplexml_load_string( $resp );
+               $this->assertNotType( "bool", $sxe );
+               $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
                $a = $sxe->login[0]->attributes()->result;
                $this->assertEquals( ' result="Success"', $a->asXML() );
        }
@@ -60,15 +60,15 @@ class MediaWikiAPITest extends MediaWikiAPI_TestCase {
        function testApiGotCookie() {
                global $wgScriptPath, $wgServerName;
 
-               $req = HttpRequest::factory(self::$apiUrl."?action=login&format=xml",
-                                                                       array("method" => "POST",
+               $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
+                                                                       array( "method" => "POST",
                                                                                  "postData" => array(
                                                                                          "lgname" => self::$userName,
-                                                                                         "lgpassword" => self::$passWord)));
+                                                                                         "lgpassword" => self::$passWord ) ) );
                $req->execute();
                $cj = $req->getCookieJar();
 
-               $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName='.self::$userName.'; .*Token=/',
-                                                        $cj->serializeToHttpRequest($wgScriptPath, $wgServerName) );
+               $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/',
+                                                        $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName ) );
        }
 }